<template>
  <div class="app-container">
    <div v-if="step === 1">
      <el-table :data="userCheckoutList" stripe size="mini">
        <el-table-column label="用户姓名" width="200" align="left" prop="name">
          <template slot-scope="scope">
            <el-link type="primary" @click="clickAUser(scope)">{{ scope.row.name }}</el-link>
          </template>
        </el-table-column>
        <el-table-column label="用户电话" width="200" align="left" prop="mobile" />
        <el-table-column label="用户邮箱" width="200" align="left" prop="email" />
        <el-table-column label="所属部门" width="200" align="left" prop="deptname" />
        <el-table-column label="资产数量" width="100" align="center" prop="asset_num" />
        <el-table-column label="许可证数量" width="100" align="center" prop="license_num" />
        <el-table-column label="附属品数量" width="100" align="center" prop="accessory_num" />
        <el-table-column label="消耗品品数量" width="100" align="center" prop="accessory_num" />
      </el-table>
      <pagination
        v-show="total > 0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </div>
    <div v-if="step === 2">
      <detail :top-id="topId" :choose-item="chooseItem" @fanhui="fanhui"></detail>
    </div>
  </div>
</template>

<script>

import { getUserCheckoutReport } from "@/api/vadmin/report/index";
import detail from "./detail";

export default {
  name: "UserCheckoutReport",
  components: {
    detail
  },
  data() {
    return {
      step: 1,
      userCheckoutList: [],
      // 总条数
      total: 0,
      topId: 0,
      chooseItem: null,
      queryParams: {
        pageNum: 1,
        pageSize: 50
      }
    };
  },
  mounted() {
    this.step = 1;
    this.getList();
  },
  methods: {
    fanhui() {
      this.step = 1;
    },
    getList() {
      getUserCheckoutReport(this.queryParams).then(res => {
        this.userCheckoutList = res.data.results;
        this.total = res.data.count;
      });
    },
    clickAUser(scope) {
      this.chooseItem = scope.row;
      this.step = 2;
      this.topId = scope.row.id;
    }
  }
};
</script>

<style lang="scss" scoped></style>
